import Mock from 'mockjs'
import {login, logout, getUserInfo} from './login'
import {getTableData} from './data'
import {listUser, removeUser, updateRemark, updateUser, addUser} from './user'

// 登录相关和获取用户信息
Mock.mock(/\/login/, login)
Mock.mock(/\/get_info/, getUserInfo)
Mock.mock(/\/logout/, logout)
Mock.mock(/\/get_table_data/, getTableData)
Mock.mock(/\/user_service\/user/, (opts) => {
  if (opts.type === 'DELETE') {
    return removeUser()
  } else if (opts.type === 'PATCH') {
    return updateUser()
  } else if (opts.type === 'POST') {
    return addUser()
  }
    return listUser();
})

export default Mock
